﻿using System.Reflection;
using Riba.MVVMSL;

namespace MVVMtutorialAdvanced
{
	public class MainPage_VM : ViewModelBase
	{
		public string Version
		{
			get
			{
				var assembly = Assembly.GetExecutingAssembly(); 
				var name = new AssemblyName(assembly.FullName);
				return "MVVMtutorialAdvanced Version " + name.Version.ToString(3);
			}
		}
		public RelayCommand CommandMenu { get; private set; }

		public MainPage_VM()
		{
			CommandMenu = new RelayCommand
				(
					cmdPar =>
					{
						NavigateToViewEventArgs p;

						if (cmdPar.ToString() == "Authors")
							p = new NavigateToViewEventArgs(typeof(Author), AnimationMode.Forward);
						else if (cmdPar.ToString() == "Books")
							p = new NavigateToViewEventArgs(typeof(Books), AnimationMode.Forward);
						else
							p = null;

						RaiseNavigateToView(p);
					}
				) { IsEnabled = true };
		}
	}
}
